﻿ {include file="public/header" /}
<body>
<div class="x-body ">
  <form  class="layui-form">
    <div class="layui-form-item">
      <label class="layui-form-label">单据编号</label>
      <span style="color: red">*</span>
      <div class="layui-input-inline">
        <input type="text" value="{$newId}" disabled name="deliveryId" lay-verify="required" autocomplete="off" class="layui-input" >
        <input type="hidden" value="{$Think.session.user.user_name}" disabled name="create_name">
        <input type="hidden" value="{:date('Y-m-d H:i:s')}" name="document" lay-verify="required" autocomplete="off" class="layui-input" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">客户名称</label>
      <div class="layui-input-block">
        <select name="clientName" lay-search="">
          <option value=""></option>
          {volist name="clientInfo" id="info"}
          <option value="{$info.id}">{$info.client_abbreviation} - {$info.client_name?$info.client_name:"无全称"}</option>
          {/volist}
        </select>
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">收款账户</label>
      <div class="layui-input-block">
        <input type="text" name="accounts" lay-verify="required" autocomplete="off" class="layui-input" >
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">单据说明</label>
      <div class="layui-input-block">
        <input type="text" name="deliveryText" lay-verify="required" autocomplete="off" class="layui-input" >
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">收款金额</label>
      <div class="layui-input-block">
        <input type="text" name="amount" lay-verify="required" autocomplete="off" class="layui-input" >
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">是否打印</label>
      <div class="layui-input-block">
        <input type="checkbox" name="if_print" lay-skin="switch" lay-text="是|否">
      </div>
    </div>
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">备注</label>
      <div class="layui-input-block">
        <input type="text" name="remarks" lay-verify="required" autocomplete="off" class="layui-input" >
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label"></label>
      <button class="layui-btn" lay-submit lay-filter="addId" >
        增加
      </button>
    </div>
  </form>
</div>
<script>
    layui.use(['form'], function(){

        $ = layui.jquery;
        var form = layui.form,layer = layui.layer;

        //监听提交
        form.on('submit(addId)', function(data){
            console.log(data);
            $.post("{:url('index/Delivery/addCreate')}",data.field,function(info){
                if (info) {
                    layer.alert("添加成功", {icon: 6},function () {
                        window.parent.location.reload();  //刷新父级页面
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前弹出层
                        parent.layer.close(index);
                    });
                }else{
                    layer.alert("添加失败", {icon: 5});
                }
            },'json');
            return false;
        });
    });
</script>
</body>

</html>